<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="format-detection" content="telephone=no" />
	<title>品睿教育</title>
	<style type="text/css">
		*{
			padding: 0;
			margin: 0;
		}
		.main{
			/* width: 96vw; */
			margin: 0 auto;
			padding-top: 1rem;
			background-color: #FAFAFA;
		}
		.main .content{
			padding-top: 1rem;
			background-color: #FFFFFF;
			display: flex;
			flex-direction: column;
			align-items: center;
		}
		.logo{
			width: 8rem;
			height: 8rem;
			margin: 1rem auto;
		}
		.main .content .btn{
			color: white;
			display: block;
			text-decoration: none;
			width: 14rem;
			height: 3rem;
			line-height: 3rem;
			text-align: center;
			background-color: #C00000;
			-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
			-webkit-user-select: none;
			-moz-user-focus: none;
			-moz-user-select: none;
			border-radius: .5rem;
			font-weight: bold;
			letter-spacing: .2rem;
		}
		.publicity{
			width: 22rem;
			padding-top: 4rem;
			margin: 0 auto;
		}
		#guide {
			position: absolute;
			top: 0;
			width: 100%;
			height: 100%;
			left: 0;
			background-color: black;
			opacity: 0.7;
		}
		#guide div{
			position: relative;
			width: 100%;
			height: 100%;
		}
		#guide .arrows{
			position: absolute;
			top: 0;
			right: 0;
			width: 20%;
			height: 20%;
		}
		#guide .text{
			margin-top: 200px;
			margin: 200px 50px;
			width: 275px;
			height: 15%;
		}
	</style>
  </head>
  <body>
	<div class="main">
		<div class="content">
			<img src="http://app.pinruiedu.com/share1.png" alt="品睿logo" class="logo" />
			<button class="btn" id="btn">打开软件</button>
			<img src="http://app.pinruiedu.com/share2.png" alt="品睿宣传图" class="publicity" />
		</div>
		<div id="guide">
			<div>
				<img src="http://app.pinruiedu.com/share5.png" alt="" class="arrows">
				<img src="http://app.pinruiedu.com/share4.png" alt="" class="text">
			</div>
		</div>
	</div>
<script type="text/javascript">
	
//禁止双指放大
document.documentElement.addEventListener('touchstart', function (event) {
  if (event.touches.length > 1) {
	event.preventDefault();
  }
}, false);

//禁止双击放大
var lastTouchEnd = 0;
document.documentElement.addEventListener('touchend', function (event) {
  var now = Date.now();
  if (now - lastTouchEnd <= 300) {
	event.preventDefault();
  }
  lastTouchEnd = now;
}, false);

window.onload = function(){
	let btn = document.getElementById("btn");
	let guide = document.getElementById("guide");
    if(isWeiXin()){
        btn.style.display = "none";
		guide.style.display = "block";
    }else{
		btn.style.display = "block";
		guide.style.display = "none";
		//  不是微信
	}
}
function isWeiXin(){
    var ua = window.navigator.userAgent.toLowerCase();
    if(ua.match(/MicroMessenger/i) == 'micromessenger'){
        return true;
    }else{
        return false;
    }
}

var btn = document.getElementById("btn");
btn.onclick = function() {
		var agent = navigator.userAgent.toLowerCase();
		var equipmentAndroid = agent.indexOf("android");
		var equipmentIphone = agent.indexOf("iphone");
		var equipmentIpad = agent.indexOf("ipad");
		var equipment = {
			android: false,
			ios: false,
		}
		if(equipmentAndroid != -1){
			equipment.android = true;
		}
		if(equipmentIphone != -1 || equipmentIpad != -1){
			equipment.ios = true;
		}
      // 判断手机上是否安装了app，如果安装直接打开url，如果没安装，执行callback
      function openApp(url, callback) {
        if (equipment.android || equipment.ios) {
          var timeout, t = 1500, hasApp = true;
          var openScript = setTimeout(function () {
            if (!hasApp) {
              callback && callback()
            }
            document.body.removeChild(ifr);
          }, 2500)
          var t1 = Date.now();
          var ifr = document.createElement("iframe");
          ifr.setAttribute('src', url);
          ifr.setAttribute('style', 'display:none');
          document.body.appendChild(ifr);
          timeout = setTimeout(function () {
            var t2 = Date.now();
            if (t2 - t1 < t + 100) {
              hasApp = false;
              mask[0].style.display = "none"
            }
          }, t);
        }
      }
      //跳h5
      function goConfirmAddr() {
        window.location.href = 'https://a.app.qq.com/o/simple.jsp?pkgname=pingruiedu.keystore'
      }
      if (equipment.android) {
		goConfirmAddr()
        openApp("PinRuiEduApp://", goConfirmAddr)
      }
      if (equipment.ios) {
		goConfirmAddr()
        openApp("PinRuiEduApp://", goConfirmAddr)
      }
    }
</script>
  </body>
</html>
